package cn.colat.micse.gateway.config;

/* import cn.colat.micse.common.code.ResCode;
import cn.colat.micse.common.pojo.vo.ResBody;
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.BlockRequestHandler;
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.ServerResponse;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono; */

/**
 * sentinel 网关配置
 **/

// @Configuration
public class SentinelGatewayConfig {

    /* public SentinelGatewayConfig() {
        GatewayCallbackManager.setBlockHandler(new BlockRequestHandler() {
            //网关限流了请求，就会调用此回调
            @Override
            public Mono<ServerResponse> handleRequest(ServerWebExchange exchange, Throwable t) {

                ResBody<String> error = ResBody.failErrorCode(ResCode.TO_MANY_REQUEST);
                String errorJson = JSONObject.toJSONString(error);
                Mono<ServerResponse> body = ServerResponse.ok().body(Mono.just(errorJson), String.class);
                return body;
            }
        });
    } */

}
